<html>
<head><meta charset="utf-8"><title>Alternatives to `ty::WithOptConstParam` · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html">Alternatives to `ty::WithOptConstParam`</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="212234795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212234795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212234795">(Oct 04 2020 at 18:21)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span>  I had a hard time understanding the intended usage of this type in <a href="https://github.com/rust-lang/rust/issues/77430">#77430</a>. Mostly this is because I ran into a problem for which the recommended usage, "call <code>try_upgrade</code> at the start of each query" was not sufficient. It's not a high priority, but I have a few ideas to reduce the surface area of this type. However, they might be based on some false assumptions about the semantics of <code>WithOptConstParam</code>. Namely:</p>
<ul>
<li>Its only purpose is to avoid cyclic queries due to <code>typeof</code>.</li>
<li><strong>Either</strong> each MIR body will only be associated with exactly one const generic parameter, <strong>or</strong> each MIR body may be associated with multiple const generic parameters, but all parameters have the same type.</li>
</ul>
<p>If both of these are true, I don't see why we couldn't use a side-table (a mapping of each MIR body <code>DefId</code> to the <code>DefId</code> of an associated const generic parameter) in the implementation of <code>typeof</code> and hide this complexity everywhere. This seems a bit too easy, so I'm sure I'm missing something here, but maybe we can find a "middle path".</p>



<a name="212234877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212234877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212234877">(Oct 04 2020 at 18:23)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="119009">@eddyb</span> here</p>
<p>How do you want to build this side table? We only know the type of the relevant param during typeck and do not exit typeck before we need it, so we would need to somehow break the query abstraction for this to work</p>



<a name="212235059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235059">(Oct 04 2020 at 18:26)</a>:</h4>
<p>I already tried using a sidetable here, there are some annoying interactions I still remember.</p>



<a name="212235072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235072">(Oct 04 2020 at 18:27)</a>:</h4>
<p>firstly, what happens if we use <code>a.this_functions_doesnt_exist&lt;13&gt;</code></p>



<a name="212235123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235123">(Oct 04 2020 at 18:28)</a>:</h4>
<p>here we end up calling <code>type_of</code> for the anon const without ever finding the correct param (as it doesn't exist)</p>



<a name="212235145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235145">(Oct 04 2020 at 18:29)</a>:</h4>
<p>that one is avoidable, more concerning is the following:</p>



<a name="212235146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235146">(Oct 04 2020 at 18:29)</a>:</h4>
<p>In my half-baked idea, the mapping would just be the <code>DefId</code> of the const-generic parameter for which a given MIR body is substituted, not its type.</p>



<a name="212235199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235199">(Oct 04 2020 at 18:30)</a>:</h4>
<p>yeah, but we only know that <code>DefId</code> once we are inside of <code>typeck_tables_of</code> for the containing body</p>



<a name="212235210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235210">(Oct 04 2020 at 18:30)</a>:</h4>
<p>Is that a fundamental limitation or a derived one?</p>



<a name="212235212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235212">(Oct 04 2020 at 18:30)</a>:</h4>
<p>fundamental</p>



<a name="212235226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235226">(Oct 04 2020 at 18:31)</a>:</h4>
<p>let me get an example</p>



<a name="212235282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235282">(Oct 04 2020 at 18:32)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#![feature(const_generics)]</span><span class="w"></span>

<span class="k">struct</span> <span class="nc">A</span><span class="p">;</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">usize</span> <span class="p">{</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">B</span><span class="p">;</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="n">B</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">M</span>: <span class="kt">isize</span><span class="o">&gt;</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">usize</span> <span class="p">{</span><span class="w"> </span><span class="mi">42</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">A</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="n">a</span><span class="p">.</span><span class="n">foo</span>::<span class="o">&lt;</span><span class="mi">7</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="212235293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235293">(Oct 04 2020 at 18:32)</a>:</h4>
<p>is the param for <code>7</code> <code>N</code> or <code>M</code> here</p>



<a name="212235301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235301">(Oct 04 2020 at 18:33)</a>:</h4>
<p>we don't know this until we know the type of <code>a</code></p>



<a name="212235302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235302">(Oct 04 2020 at 18:33)</a>:</h4>
<p>for which we have to typeck <code>main</code></p>



<a name="212235396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235396">(Oct 04 2020 at 18:35)</a>:</h4>
<p>Got it. It's highly unlikely I'll be able to offer any new ideas here, so I'll change course. Is it possible to deduplicate the <code>*_mir</code> queries given that, once type-checking is complete, the mapping from MIR body to const parameter won't change?</p>



<a name="212235485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235485">(Oct 04 2020 at 18:37)</a>:</h4>
<p>I haven't thought very hard about this</p>



<a name="212235660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235660">(Oct 04 2020 at 18:40)</a>:</h4>
<p>you mean <code>optimized_mir</code> with <code>optimized_mir_of_const_arg</code>?</p>



<a name="212235723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235723">(Oct 04 2020 at 18:42)</a>:</h4>
<p>Yes, that's the duplication I'm referring to.</p>



<a name="212235743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235743">(Oct 04 2020 at 18:43)</a>:</h4>
<p>this happens because we can only encode things by <code>DefIndex</code> afaik</p>



<a name="212235767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235767">(Oct 04 2020 at 18:44)</a>:</h4>
<p>so we can't encode a query if it uses <code>ty::WithOptConstParam</code> as we would have to encode both the <code>did</code> and the <code>const_param_did</code></p>



<a name="212235820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235820">(Oct 04 2020 at 18:45)</a>:</h4>
<p>and iirc it improved perf to split these queries as some of them are rather hot and it costs slightly more to hash and compare a <code>WithOptConstParam</code> than it does for a <code>DefId</code></p>



<a name="212235898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235898">(Oct 04 2020 at 18:47)</a>:</h4>
<p>Okay, so everything that needs to be encoded cross-crate has to be split, while everything else can take <code>ty::WithOptConstParam</code></p>



<a name="212235905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212235905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212235905">(Oct 04 2020 at 18:47)</a>:</h4>
<p>I mostly think so, yeah</p>



<a name="212236126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212236126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212236126">(Oct 04 2020 at 18:52)</a>:</h4>
<p>Hmm, I'll need to look at the code a bit more, but I doubt that I'll be able to do better. Some documentation about why the query split happens would have helped me, as would using a proper <code>struct</code> for the <code>(DefId, LocalDefId)</code> pair. That might just be a personal problem. Maybe we should wait to see if this causes issues for other refactors?</p>



<a name="212236142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212236142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212236142">(Oct 04 2020 at 18:52)</a>:</h4>
<p><code>WithConstParam</code>? <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="212236209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212236209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212236209">(Oct 04 2020 at 18:54)</a>:</h4>
<blockquote>
<p>That might just be a personal problem. Maybe we should wait to see if this causes issues for other refactors?</p>
</blockquote>
<p>It doesn't help to preemptively add more docs, bad enough that you had some issues</p>



<a name="212236218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212236218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212236218">(Oct 04 2020 at 18:54)</a>:</h4>
<p>I could see having to remember which is the const-param and which is the real thing causing problems in the future.</p>



<a name="212236241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212236241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212236241">(Oct 04 2020 at 18:55)</a>:</h4>
<p>yeah, so naming stuff won't hurt</p>



<a name="212236242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212236242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212236242">(Oct 04 2020 at 18:55)</a>:</h4>
<p>When you're calling a cross-crate encoded query on a <code>LocalDefId</code></p>



<a name="212236252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212236252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212236252">(Oct 04 2020 at 18:55)</a>:</h4>
<p>But that's just a small nitpick, it doesn't make anything simpler.</p>



<a name="212236272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212236272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212236272">(Oct 04 2020 at 18:56)</a>:</h4>
<p>it also makes it easier to cross-reference with <code>WithOptConstParam</code> in the docs</p>



<a name="212236478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212236478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212236478">(Oct 04 2020 at 19:01)</a>:</h4>
<p>Once my <code>MirSource</code> PR lands, I'll open one that removes the hack in MIR building and includes some changes to the documentation of <code>WithOptConstParam</code> that I would have found helpful now that I know a bit more.</p>



<a name="212236487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212236487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212236487">(Oct 04 2020 at 19:01)</a>:</h4>
<p>Anyways, thanks for taking the time to explain stuff to me!</p>



<a name="212236538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212236538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212236538">(Oct 04 2020 at 19:02)</a>:</h4>
<p>Funnily enough, all of this arose out of a desire to use <code>dump_mir</code> in the dataflow framework (which passes a <code>(DefId, Body)</code> everywhere).</p>



<a name="212236554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212236554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212236554">(Oct 04 2020 at 19:03)</a>:</h4>
<p>Things really got out of hand.</p>



<a name="212241384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241384">(Oct 04 2020 at 20:54)</a>:</h4>
<p>hi, taking a look now</p>



<a name="212241403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241403">(Oct 04 2020 at 20:55)</a>:</h4>
<p><span class="user-mention" data-user-id="118594">@ecstatic-morse</span> there's no way to soundly do this any other way AFAIK</p>



<a name="212241409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241409">(Oct 04 2020 at 20:55)</a>:</h4>
<p>like this approach is the only reason we can support this at all</p>



<a name="212241452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241452">(Oct 04 2020 at 20:56)</a>:</h4>
<p>before <span class="user-mention" data-user-id="121053">@varkor</span> and I debated it I was sure we couldn't support the things that need this trick</p>



<a name="212241472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241472">(Oct 04 2020 at 20:57)</a>:</h4>
<p>so I don't think cross-crate is the performance problem, it's incremental caches, including in-memory</p>



<a name="212241520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241520">(Oct 04 2020 at 20:58)</a>:</h4>
<p>^ ah yeah, incremental caches also only work with one <code>DefId</code></p>



<a name="212241525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241525">(Oct 04 2020 at 20:58)</a>:</h4>
<p>I think I had some comments about the names in the source code, but IIRC <span class="user-mention" data-user-id="216206">@lcnr</span> addressed most of them</p>



<a name="212241602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241602">(Oct 04 2020 at 21:00)</a>:</h4>
<p>one idea I had was naming it by <em>what it's for</em>, rather than <em>what it is</em></p>



<a name="212241606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241606">(Oct 04 2020 at 21:00)</a>:</h4>
<p>so something more like <code>BodyTypeckId</code> or similar</p>



<a name="212241608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241608">(Oct 04 2020 at 21:01)</a>:</h4>
<p>Yeah, you can see in the thread that I didn't really understand the requirements here. It'd be nice to remove the duplicate MIR queries, but that also seems difficult, and I have less expertise than either of you. I  would have chosen a slightly different API, but that's more of a personal preference.</p>



<a name="212241620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241620">(Oct 04 2020 at 21:01)</a>:</h4>
<p>would deduplicating the queries help with anything?</p>



<a name="212241622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241622">(Oct 04 2020 at 21:01)</a>:</h4>
<p>the <code>_of_const_arg</code> queries are internal helpers, really</p>



<a name="212241628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241628">(Oct 04 2020 at 21:01)</a>:</h4>
<p>just because it's a massive pain to get the same effect otherwise</p>



<a name="212241638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241638">(Oct 04 2020 at 21:02)</a>:</h4>
<p>No, just conceptual overhead. Once you understand that you have to do <code>try_upgrade</code> at the start, it's pretty straightforward</p>



<a name="212241648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241648">(Oct 04 2020 at 21:02)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60/near/212241622">said</a>:</p>
<blockquote>
<p>the <code>_of_const_arg</code> queries are internal helpers, really</p>
</blockquote>
<p>we don't have a method for them because I was lazy</p>



<a name="212241687"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241687" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241687">(Oct 04 2020 at 21:02)</a>:</h4>
<p><span class="user-mention" data-user-id="118594">@ecstatic-morse</span> I see. yeah, there should be comments on everything pointing to the main documentation thing</p>



<a name="212241695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241695">(Oct 04 2020 at 21:02)</a>:</h4>
<p>so for some queries we still use </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">if</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nb">Some</span><span class="p">((</span><span class="n">did</span><span class="p">,</span><span class="w"> </span><span class="n">const_param_did</span><span class="p">))</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">,,.,</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="c1">// ..</span>
<span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="c1">// ..</span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="212241700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241700">(Oct 04 2020 at 21:03)</a>:</h4>
<p>should just clean this up, will do that rn</p>



<a name="212241707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241707">(Oct 04 2020 at 21:03)</a>:</h4>
<p>a name like <code>BodyTypeckId</code> or <code>TypeckBodyId</code> or w/e would also be more instantly recognizable</p>



<a name="212241844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241844">(Oct 04 2020 at 21:07)</a>:</h4>
<p><span class="user-mention" data-user-id="118594">@ecstatic-morse</span> oh the other thing is we should switch the macros so we can have arbitrary numbers of query inputs :D</p>



<a name="212241892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241892">(Oct 04 2020 at 21:08)</a>:</h4>
<p>So there's three states here AFAICT, either we know a body is associated with a const-generic parameter, we know it isn't, or we don't know either way. I think it would have helped me if this were encoded into the type system more explictly, since currently <code>(DefId, LocalDefId)</code> is used to represent the first and <code>WithOptConstParam</code> can represent any of them. Doing this might result in worse ergonomics however. I trust y'all to evaluate the trade-offs better than I can.</p>



<a name="212241894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241894">(Oct 04 2020 at 21:08)</a>:</h4>
<p>for the <code>Key</code> type, we can shove them into <code>($($arg_ty),*)</code> so that a single <code>T</code> becomes <code>(T)</code> i.e. still <code>T</code> but no arguments becomes <code>()</code>, two arguments becomes <code>(T, U)</code> etc.</p>



<a name="212241895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241895">(Oct 04 2020 at 21:08)</a>:</h4>
<p>been meaning to do this for almost a year now, I wonder if <span class="user-mention" data-user-id="281572">@marmeladema</span> was looking at this at some point</p>



<a name="212241911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241911">(Oct 04 2020 at 21:09)</a>:</h4>
<p><span class="user-mention" data-user-id="118594">@ecstatic-morse</span> it's kind of a hack rn, it would probably work better if we slapped more specific names on it</p>



<a name="212241912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241912">(Oct 04 2020 at 21:09)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60/near/212241844">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="118594">ecstatic-morse</span> oh the other thing is we should switch the macros so we can have arbitrary numbers of query inputs <span aria-label="grinning" class="emoji emoji-1f600" role="img" title="grinning">:grinning:</span></p>
</blockquote>
<p>My heart starts beating a little faster every time I open <code>plumbing.rs</code>.</p>



<a name="212241942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241942">(Oct 04 2020 at 21:10)</a>:</h4>
<p>also, you know how <code>Option&lt;DefId&gt;</code> / <code>Option&lt;LocalDefId&gt;</code> are the same size as the inner type, right?</p>



<a name="212241975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241975">(Oct 04 2020 at 21:11)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">enum</span> <span class="nc">TypeckBodyIdContext</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Unknown</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="nb">None</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">ConstParam</span><span class="p">(</span><span class="n">DefId</span><span class="p">),</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="212241977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241977">(Oct 04 2020 at 21:11)</a>:</h4>
<p>this would also be the same size as <code>DefId</code></p>



<a name="212241983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241983">(Oct 04 2020 at 21:11)</a>:</h4>
<p>because of how we reserve like 256 invalid values :D</p>



<a name="212241992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212241992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212241992">(Oct 04 2020 at 21:11)</a>:</h4>
<p>so it shouldn't really cost us anything to be more precise here</p>



<a name="212242032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212242032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212242032">(Oct 04 2020 at 21:12)</a>:</h4>
<p>Big <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span> for that. I think it would have helped me at least.</p>



<a name="212242042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212242042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212242042">(Oct 04 2020 at 21:13)</a>:</h4>
<p><span class="user-mention silent" data-user-id="118594">ecstatic-morse</span> <a href="#narrow/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60/near/212241912">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60/near/212241844">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="118594">ecstatic-morse</span> oh the other thing is we should switch the macros so we can have arbitrary numbers of query inputs :D</p>
</blockquote>
<p>My heart starts beating a little faster every time I open <code>plumbing.rs</code>.</p>
</blockquote>
<p>the trick to working on complex things is to ignore anything that is not directly relevant heh</p>



<a name="212242044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212242044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212242044">(Oct 04 2020 at 21:13)</a>:</h4>
<p>like this is entirely a minor macro change</p>



<a name="212242098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212242098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212242098">(Oct 04 2020 at 21:14)</a>:</h4>
<p>tempted to go do it myself if nobody else wants to :D</p>



<a name="212242124"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212242124" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212242124">(Oct 04 2020 at 21:15)</a>:</h4>
<p>/me doesn't want to <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="212242451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Alternatives%20to%20%60ty%3A%3AWithOptConstParam%60/near/212242451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60.html#212242451">(Oct 04 2020 at 21:25)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/131828-t-compiler/topic/Alternatives.20to.20.60ty.3A.3AWithOptConstParam.60/near/212241700">said</a>:</p>
<blockquote>
<p>should just clean this up, will do that rn</p>
</blockquote>
<p>opened <a href="https://github.com/rust-lang/rust/issues/77550">#77550</a> for that</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>